<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
</head>
<body>
    <div class="nav">
        导航
    </div>
    <!-- 当我的窗口距离顶部达到200px,我就让nav完全显示 -->
    <script>
        $(window).scroll(function(){
            // 获取滚动条距离顶部的距离
            var scrollTop = $(window).scrollTop();
            // console.log(scrollTop)
            var opacity = scrollTop/300;
            
            if(opacity>1){
                opacity=1
            }
            $(".nav").css({opacity:opacity})
        })
    </script>
</body>
</html>